package com.Mt.Serviceimpl;

import com.Mt.Service.MtInviteService;
import com.Mt.mapper.MtInviteMapper;
import com.Mt.pojo.MtInvite;
import com.Mt.pojo.Page;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * (MtInvite)表服务实现类
 *
 * @author 陈旭超 买茶送包
 * @since 2020-12-07 10:12:23
 */
@Service
public class MtInviteServiceImpl implements MtInviteService {

    @Autowired
    private MtInviteMapper mtInviteMapper;

    public Page<MtInvite> page(String userId,int index) {
        int size = 10;// 每一页显示多少条数据
        // 总共有多少数据
        int count = mtInviteMapper.count(userId);
        // 可以分成多少页
        int pageEnd = count % size == 0 ? count / size : count / size + 1;
        Page page = new Page();
        page.setCount(count);
        page.setPageEnd(pageEnd);
        page.setData(mtInviteMapper.page(userId,(index-1)*size,size));
        return page;
    }
    public MtInvite queryById(String userId) {
        return mtInviteMapper.queryById(userId);
    }

    public int add(MtInvite mtInvite) {
        return mtInviteMapper.add(mtInvite);
    }

    public int upd(MtInvite mtInvite) {
        return mtInviteMapper.upd(mtInvite);
    }

    public int updShare(MtInvite mtInvite) {
        return mtInviteMapper.updShare(mtInvite);
    }
}